import Axios from 'axios';
import store from '../store'
import {getToken} from "./token";

const instance = Axios.create({
    baseURL:'http://127.0.0.1:8088/',
    timeout:5000
});

instance.interceptors.request.use(
    config =>{
        if (store.getters.token){
            config.headers['Token'] = getToken()
        }
        return config;
    },
        error => {
        return Promise.reject(error)
    }
)

instance.interceptors.response.use(
    response => response,
    error => {
        return Promise.reject(error);
    }
)

export default instance